﻿using MesProjectWinform.BasicData.基础实现.Bom;
using MesProjectWinform.BasicData.基础实现.chan;
using MesProjectWinform.BasicData.基础实现.chanpin;
using MesProjectWinform.BasicData.基础实现.gongwei;
using MesProjectWinform.BasicData.基础实现.gongyings;
using MesProjectWinform.BasicData.基础实现.kehu;
using MesProjectWinform.BasicData.基础实现.wuliao;
using MesProjectWinform.BasicData.基础实现.显示页面;
using MesProjectWinform.Equipment.Form.DeviceLedger;
using MesProjectWinform.Equipment.Form.DeviceType;
using MesProjectWinform.Equipment.Form.LargeScreen;
using MesProjectWinform.Equipment.Form.ProjectFrom;
using MesProjectWinform.Equipment.Form.ProjectMaintenance;
using MesProjectWinform.Helper;
using MesProjectWinform.Production.Forms;
using MesProjectWinform.Production.Forms.Packing;
using MesProjectWinform.Production.Forms.ProductionPlaning;
using MesProjectWinform.Production.Forms.ProductionReport;
using MesProjectWinform.Production.Forms.ProductLock;
using MesProjectWinform.Public.Form;
using MesProjectWinform.WareHouse;
using MesProjectWinform.WareHouse.Form.仓库定义;
using MesProjectWinform.WareHouse.Form.外部标签解析;
using MesProjectWinform.WareHouse.Form.工序分类;
using MesProjectWinform.WareHouse.Form.工序排序;
using MesProjectWinform.WareHouse.Form.工序管理;
using MesProjectWinform.WareHouse.Form.库位;
using MesProjectWinform.WareHouse.Form.数据维护;
using MesProjectWinform.WareHouse.Form.来料标签打印;
using MesProjectWinform.WareHouse.Form.货位库区;
using System;
using System.Drawing;
using System.Windows.Forms;

namespace MesProjectWinform
{
    public partial class MainForm : DevExpress.XtraBars.Ribbon.RibbonForm
    {
        public MainForm()
        {
            InitializeComponent();
            
            // 订阅窗体关闭事件
            this.FormClosing += MainForm_FormClosing;
        }
        
        /// <summary>
        /// 窗体关闭时确保清理资源
        /// </summary>
        private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            // 关闭大屏显示
            CloseDashboard();
        }

        /// <summary>
        /// 打开指定类型的子窗体，如果已打开则激活，不允许重复打开。
        /// </summary>
        /// <typeparam name="F">要打开的窗体类型，必须继承自XtraForm并有无参构造函数。</typeparam>
        /// <param name="alone">是否只允许单例（true为只允许一个实例）</param>
        private void Disabled<F>(bool alone) where F : DevExpress.XtraEditors.XtraForm, new()
        {
            if (alone)
            {
                // 遍历所有Mdi子窗体，查找是否已存在指定类型的窗体
                foreach (Form form in this.MdiChildren)
                {
                    if (form.GetType() == typeof(F))
                    {
                        // 已存在则激活该窗体并返回
                        form.Activate();
                        return;
                    }
                }
            }
            // 未找到则新建一个窗体实例并显示
            F f = new F();
            f.MdiParent = this;
            f.Show();
        }
        /// <summary>
        /// 车间定义
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void navBarItem1_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            Disabled<chejian>(true);
        }

        /// <summary>
        /// 仓库定义
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void WareHouse_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            Disabled<Form_WareHouse>(true);
        }
        /// <summary>
        /// 产线定义
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void navBarItem3_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            Disabled<chanxian>(true);
        }
        /// <summary>
        /// 工位定义
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        private void navBarItem4_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            Disabled<gongwei>(true);
            
        }
        /// <summary>
        /// 设备类型定义
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DeviceTypeBarItem2_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            Disabled<DeviceTypeForm>(true);
        }
     

        private void MainForm_Load(object sender, EventArgs e)
        {
            // 初始化大屏显示并添加到主窗体中
            InitializeDashboard();
            
            // 根据用户职位控制导航栏节点的显示
            if (RequestUser.CurrentUser.JobName == JobEnum.厂长.ToString())
            {
                // 厂长可以看到所有节点，不需要额外处理
            }
            else
            {
                // 非厂长用户，隐藏所有导航组和项目
                //HideAllNavItems();
                
                // 根据不同职位显示对应的节点
                ShowNavItemsByJobRole(RequestUser.CurrentUser.JobName);
            }
        }
        
        /// <summary>
        /// 初始化大屏显示并将其嵌入到主窗体
        /// </summary>
        private void InitializeDashboard()
        {
            try
            {
                // 创建容器面板来放置大屏显示
                Panel dashboardContainer = new Panel();
                dashboardContainer.Dock = DockStyle.Fill;
                
                // 创建大屏显示窗体实例
                daping dashboardForm = new daping();
                
                // 设置窗体为子控件形式
                dashboardForm.TopLevel = false;
                dashboardForm.FormBorderStyle = FormBorderStyle.None;
                dashboardForm.Dock = DockStyle.Fill;
                
                // 将大屏窗体添加到面板容器
                dashboardContainer.Controls.Add(dashboardForm);
                
                // 创建一个新的MDI子窗体来容纳面板
                DevExpress.XtraEditors.XtraForm containerForm = new DevExpress.XtraEditors.XtraForm();
                containerForm.Text = "实时数据大屏";
                containerForm.MdiParent = this;
                containerForm.WindowState = FormWindowState.Maximized;
                containerForm.Controls.Add(dashboardContainer);
                
                // 添加关闭按钮到容器
                DevExpress.XtraEditors.SimpleButton closeButton = new DevExpress.XtraEditors.SimpleButton();
                closeButton.Text = "关闭大屏";
                closeButton.Appearance.BackColor = Color.FromArgb(0, 120, 212);
                closeButton.Appearance.ForeColor = Color.White;
                closeButton.Size = new Size(100, 30);
                closeButton.Location = new Point(dashboardContainer.Width - 110, 10);
                closeButton.Anchor = AnchorStyles.Top | AnchorStyles.Right;
                closeButton.Click += (sender, e) => 
                {
                    containerForm.Close();
                };
                dashboardContainer.Controls.Add(closeButton);
                
                // 显示容器和大屏窗体
                dashboardForm.Show();
                containerForm.Show();
                
                // 保存对容器窗体的引用，以便稍后关闭
                _dashboardContainerForm = containerForm;
            }
            catch (Exception ex)
            {
                MessageBox.Show("初始化大屏显示出错：" + ex.Message);
            }
        }

        // 保存大屏容器窗体的引用
        private DevExpress.XtraEditors.XtraForm _dashboardContainerForm;
        
        /// <summary>
        /// 关闭大屏显示
        /// </summary>
        private void CloseDashboard()
        {
            if (_dashboardContainerForm != null && !_dashboardContainerForm.IsDisposed)
            {
                _dashboardContainerForm.Close();
                _dashboardContainerForm = null;
            }
        }
        
        /// <summary>
        /// 切换大屏显示状态
        /// </summary>
        private void ToggleDashboard()
        {
            if (_dashboardContainerForm != null && !_dashboardContainerForm.IsDisposed)
            {
                CloseDashboard();
            }
            else
            {
                InitializeDashboard();
            }
        }
        
        /// <summary>
        /// 隐藏导航栏中的所有节点
        /// </summary>
        private void HideAllNavItems()
        {
            // 遍历所有导航组
            foreach (DevExpress.XtraNavBar.NavBarGroup group in navBarControl1.Groups)
            {
                group.Visible = false;
            }
            
            // 遍历所有导航项
            foreach (DevExpress.XtraNavBar.NavBarItem item in navBarControl1.Items)
            {
                item.Visible = false;
            }
        }
        
        /// <summary>
        /// 根据职位显示对应的导航节点
        /// </summary>
        /// <param name="jobName">用户职位名称</param>
        private void ShowNavItemsByJobRole(string jobName)
        {
            // 根据不同职位设置不同的权限
            switch (jobName)
            {
                case "仓管员":
                    HideAllNavItems();
                    // 显示仓库相关的导航组
                    ShowNavGroupByCaption("仓库管理");
                    // 显示仓库相关的具体功能项
                    ShowNavItemByName("WareHouse"); // 仓库定义
                    ShowNavItemByName("navBarItem9"); // 库位设置
                    ShowNavItemByName("Shelves"); // 货位定义
                    ShowNavItemByName("NBITagLabelPrint"); // 来料标签打印
                    break;
                    
                case "车间主任":
                    HideAllNavItems();
                    // 显示生产相关的导航组
                    ShowNavGroupByCaption("生产管理");
                    ShowNavGroupByCaption("基础数据");
                    ShowNavGroupByCaption("审批流程");
                    // 显示生产相关的具体功能项
                    ShowNavItemByName("navBarItem2"); // 工单定义
                    ShowNavItemByName("navBarItem6"); // 包装管理
                    ShowNavItemByName("NBIApprovalProcess");//审批流程
                    ShowNavItemByName("navBarItem3");//产线管理
                    ShowNavItemByName("navBarItem4");//工位管理
                    ShowNavItemByName("navBarItem29");//生产报工
                    ShowNavItemByName("navBarItem30");//报工审核
                    break;
                case "操作工":
                    HideAllNavItems();
                    // 显示生产相关的导航组
                    ShowNavGroupByCaption("生产管理");
                    ShowNavGroupByCaption("审批流程");
                    // 显示生产相关的具体功能项
                    ShowNavItemByName("NBIApprovalProcess");//审批流程
                    ShowNavItemByName("navBarItem29");//生产报工
                    break;

                case "生产经理":
                    HideAllNavItems();
                    // 显示生产相关的导航组
                    ShowNavGroupByCaption("生产管理");
                    ShowNavGroupByCaption("基础数据");
                    ShowNavGroupByCaption("审批流程");
                    // 显示生产相关的具体功能项
                    ShowNavItemByName("navBarItem2"); // 工单定义
                    ShowNavItemByName("navBarItem6"); // 包装管理
                    ShowNavItemByName("NBIApprovalProcess");//审批流程
                    ShowNavItemByName("navBarItem3");//产线管理
                    ShowNavItemByName("navBarItem4");//工位管理
                    ShowNavItemByName("navBarItem29");//生产报工
                    ShowNavItemByName("navBarItem30");//报工审核
                    break;

                case "设备操作员":
                    HideAllNavItems();
                    // 显示设备相关的导航组
                    ShowNavGroupByCaption("设备管理");
                    // 显示设备相关的具体功能项
                    ShowNavItemByName("DeviceTypeBarItem2"); // 设备类型定义
                    ShowNavItemByName("DeviceLedgerBarItem7"); // 设备台账定义
                    ShowNavItemByName("navBarItem8"); // 项目维护
                    ShowNavItemByName("navBarItem34"); // 项目表单
                    break;
                    
                // 可以根据需要添加更多职位的权限设置
                //default:
                //    // 默认只显示公共功能
                //    ShowNavGroupByCaption("公共信息");
                //    ShowNavItemByName("navBarItem42"); // 单据编号
                //    break;
            }
        }
        
        /// <summary>
        /// 根据标题显示导航组
        /// </summary>
        /// <param name="caption">导航组标题</param>
        private void ShowNavGroupByCaption(string caption)
        {
            foreach (DevExpress.XtraNavBar.NavBarGroup group in navBarControl1.Groups)
            {
                if (group.Caption == caption)
                {
                    group.Visible = true;
                    break;
                }
            }
        }
        
        /// <summary>
        /// 根据名称显示导航项
        /// </summary>
        /// <param name="name">导航项名称</param>
        private void ShowNavItemByName(string name)
        {
            foreach (DevExpress.XtraNavBar.NavBarItem item in navBarControl1.Items)
            {
                if (item.Name == name)
                {
                    item.Visible = true;
                    break;
                }
            }
        }
        /// <summary>
        /// 工单定义
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void navBarItem2_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            Disabled<WorkOrderForm>(true);
        }

        private void navBarItem5_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            Disabled<ProductUnLockForm>(true);
        }

        private void navBarItem6_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            Disabled<PackingForm>(true);
        }
        /// <summary>
        /// 货位定义
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Shelves_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
           Disabled<Form_Shelves>(true);
        }
        /// <summary>
        /// 双击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void navBarControl1_Click1(object sender, EventArgs e)
        {

        }
        /// <summary>
        /// 设备台账定义
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DeviceLedgerBarItem7_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            Disabled<DeviceLedgerForm>(true);
        }
        /// <summary>
        /// 产品锁定定义
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void navBarControl1_Click(object sender, EventArgs e)
        {
            
        }

        /// <summary>
        /// 库位设置
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void navBarItem9_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            Disabled<Form_Location>(true);
        }

        private void navBarItem7_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            Disabled<ProductLockForm>(true);
        }
        /// <summary>
        ///物料
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void navBarItem10_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {

        }
        /// <summary>
        /// 客户
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void navBarItem11_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {

        }

        private void navBarItem42_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            Disabled<DocCodeForm>(true);
        }
        /// <summary>
        /// 物料管理定义
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void navBarItem10_LinkClicked_1(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            Disabled<wuliao>(true);
        }
        /// <summary>
        /// 错误点击
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void navBarItem4_LinkPressed(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {

        }
        /// <summary>
        /// 项目维护定义
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void navBarItem8_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            Disabled<ProjectMaintenanceForm>(true);
        }

        /// <summary>
        /// 客户管理定义
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void navBarItem11_LinkClicked_1(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            Disabled<kehu>(true);
        }
        /// <summary>
        /// 来料标签打印定义
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void navBarItem12_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            Disabled<Form_ShowPrintcs>(true);
        }
        /// <summary>
        /// 原材暂收仓定义
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void navBarItem13_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {

        }
        /// <summary>
        /// 原材料仓定义
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void navBarItem14_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {

        }
        /// <summary>
        /// 成品仓定义
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void navBarItem15_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {

        }
        /// <summary>
        /// 出库记录定义
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void navBarItem16_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {

        }
        /// <summary>
        /// 红牌物料管控定义
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void navBarItem17_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {

        }
        /// <summary>
        /// 备料单插叙定义
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void navBarItem18_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {

        }
        /// <summary>
        /// 物料群组定义
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void navBarItem19_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {

        }
        /// <summary>
        /// 产品物料定义
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void navBarItem20_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            Disabled<chanpin>(true);
        }
        /// <summary>
        /// 替代物料定义
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void navBarItem21_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {

        }
        /// <summary>
        /// BOM定义
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void navBarItem22_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            Disabled<Bom>(true);
        }
        /// <summary>
        /// 不良类型定义
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void navBarItem23_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {

        }
        /// <summary>
        /// 不良现象定义
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void navBarItem24_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {

        }
        /// <summary>
        /// 维修方法定义
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void navBarItem25_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {

        }
        /// <summary>
        /// 供应商定义
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void navBarItem27_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            Disabled<ying>(true);
        }
        /// <summary>
        /// 生产报工定义
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void navBarItem29_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            Disabled<ProductionReportForm>(true);
        }
        /// <summary>
        /// 报工审核定义
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void navBarItem30_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {

        }
        /// <summary>
        /// 信息追溯定义
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void navBarItem32_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            Disabled<ProductionReportingForm>(true);
        }
        /// <summary>
        /// 计划排程定义
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void navBarItem33_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            Disabled<ProductionPlaningForm>(true);
        }
        
        /// <summary>
        /// 项目表单定义
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void navBarItem34_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            Disabled<ProjectFromForm>(true);
        }
        /// <summary>
        /// 计划配置定义
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void navBarItem35_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {

        }

        /// <summary>
        /// 外部标签解析
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void NBITagLabel_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            Disabled<Form_TagLable>(true);
        }

        /// <summary>
        /// 工序分类
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void NBIProcessClass_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            Disabled<Form_ProcessClass>(true);
        }

        /// <summary>
        /// 工序管理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void NBIProcessManagement_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            Disabled<Form_ProcessManag>(true);
        }

        /// <summary>
        /// 工艺流程
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void NBIProcess_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            Disabled<Form_ProcessSort>(true);
        }
        /// <summary>
        /// 采购订单
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void NBPurchaseOrder_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {

        }

        /// <summary>
        /// 到货检验
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void NBIArrivalInspection_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {

        }

        /// <summary>
        /// 审批流程
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void NBIApprovalProcess_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {

        }

        /// <summary>
        /// 部门人员职位维护
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void navBarItem9_LinkClicked_1(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            Disabled<Form_DepJobNew>(true);
            
        }
        /// <summary>
        /// 来料标签打印
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void NBITagLabelPrint_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            Disabled<Form_TagLabelPrint>(true);
        }

        /// <summary>
        /// 人员维护
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void NBIEMP_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            Disabled<Form_Emp>(true);
        }

        private void barButtonItem2_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            // 确认是否要退出登录
            if (MessageBox.Show("确定要退出登录吗?", "退出登录", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                // 清除当前用户信息
                RequestUser.CurrentUser = null;

                // 关闭主窗体
                this.Hide();

                // 显示登录窗体
                UserLoginForm loginForm = new UserLoginForm();
                loginForm.Show();

                // 关闭当前窗体
                this.Close();
            }
        }
        /// <summary>
        /// 设备类型按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DeviceTypeButtonItem3_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            //跳转到设备类型列表页面
            DeviceTypeForm deviceTypeForm = new DeviceTypeForm();
            //居中并且最大化
            deviceTypeForm.StartPosition = FormStartPosition.CenterParent;
            deviceTypeForm.WindowState = FormWindowState.Maximized  ;
            deviceTypeForm.Show();

        }
        /// <summary>
        /// BOM点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BOMButtonItem4_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            //跳转到BOM列表页面
            Bom BOM = new Bom();
            //居中并且最大化
            BOM.StartPosition = FormStartPosition.CenterParent;
            BOM.WindowState = FormWindowState.Maximized;
            BOM.Show();
        }

        /// <summary>
        /// 工单管理点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void WorkOrderButtonItem5_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            //跳转到BOM列表页面
            WorkOrderForm workOrderForm = new WorkOrderForm();
            //居中并且最大化
            workOrderForm.StartPosition = FormStartPosition.CenterParent;
            workOrderForm.WindowState = FormWindowState.Maximized;
            workOrderForm.Show();
        }

        /// <summary>
        /// 来料标签打印点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void barButtonItem6_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Form_TagLabelPrint form_TagLabelPrint = new Form_TagLabelPrint();
            //居中并且最大化
            form_TagLabelPrint.StartPosition = FormStartPosition.CenterParent;
            form_TagLabelPrint.WindowState = FormWindowState.Maximized;
            form_TagLabelPrint.Show();
        }
        /// <summary>
        /// 来料标签打印记录
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void barButtonItem7_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Form_ShowPrintcs form_ShowPrintcs = new Form_ShowPrintcs();
            //居中并且最大化
            form_ShowPrintcs.StartPosition = FormStartPosition.CenterParent;
            form_ShowPrintcs.WindowState = FormWindowState.Maximized;
            form_ShowPrintcs.Show();
        }

        /// <summary>
        /// 工序管理点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void barButtonItem9_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Form_AddProcessManag form_AddProcessManag = new Form_AddProcessManag();
            //居中并且最大化
            form_AddProcessManag.StartPosition = FormStartPosition.CenterParent;
            form_AddProcessManag.WindowState = FormWindowState.Maximized;
            form_AddProcessManag.Show();
        }
        /// <summary>
        /// 工作台点击事件
        /// </summary>
        /// 
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void navBarItem10_LinkClicked_2(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            // 切换大屏显示
            ToggleDashboard();
        }
        /// <summary>
        /// 实时大屏按钮点击事件
        /// </summary>
        private void barButtonItem10_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            // 切换大屏显示
            ToggleDashboard();
        }

        private void navBarItem12_LinkClicked_1(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            string url = "http://10.223.9.12:8075/webroot/decision/view/duchamp?viewlet=Mes%25E7%25AE%25A1%25E7%2590%2586%25E5%2588%25B6%25E9%2580%25A0%25E6%2597%25A0%25E4%25BA%25BA%25E6%259C%25BA%25E5%25A4%25A7%25E5%25B1%258F%25E5%258F%25AF%25E8%25A7%2586%25E5%258C%2596%252F%25E9%25AB%2598%25E5%25B1%2582%25E7%259C%258B%25E6%259D%25BF.fvs&page_number=1";
            System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(url) { UseShellExecute = true });
        }

        private void navBarItem13_LinkClicked_1(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            // 弹出嵌入 Vue 的仪表台页面
            string vueUrl = "http://47.110.243.157:5173";
            var dialog = new LargeScreenFrom(vueUrl);
            dialog.ShowDialog();
        }


    }
}
